package jcseg;

import org.lionsoul.jcseg.ISegment;
import org.lionsoul.jcseg.IWord;
import org.lionsoul.jcseg.dic.ADictionary;
import org.lionsoul.jcseg.dic.DictionaryFactory;
import org.lionsoul.jcseg.segmenter.SegmenterConfig;

import java.io.StringReader;

/**
 * @author cxx
 * @create 2020-04-29 16:11
 **/
public class Demo {

    /**
     * https://gitee.com/lionsoul/jcseg
     */
    public static void main(String[] args) throws Exception{
        SegmenterConfig config = new SegmenterConfig();
        ADictionary dic = DictionaryFactory.createSingletonDictionary(config);
        ISegment seg = ISegment.Type.fromIndex(ISegment.COMPLEX_MODE).factory.create(config, dic);
        //设置要分词的内容
        String str = "勿以恶小而为之，勿以善小而不为";
        seg.reset(new StringReader (str));

        //获取分词结果
        IWord word = null;
        while ( (word = seg.next()) != null ) {
            System.out.println(word.getValue());
        }
    }

}
